<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<script>
    $(function () {
        var upper = $("#upperDoctorId").val();
        var dire = $("#directorDoctorId").val();
        var doctor = $("#doctorInChargeId").val();
        selectedDoctor($("#deptStayed").val(), doctor,upper,dire);
    });
    function selectedDoctor(deptId, doctor,upper,dire){
        loadDoctorByDept(deptId, doctor,'doctorInCharge','${ctx}/sys/orgGroupVsDept/findUserByDeptId');
        loadDoctorByDept(deptId, upper,'upperDoctor','${ctx}/sys/orgGroupVsDept/findUserByDeptId');
        loadDoctorByDept(deptId, dire,'directorDoctor','${ctx}/sys/orgGroupVsDept/findUserByDeptId');
    }
</script>
<form:form id="inputForm" data-parsley-validate="" modelAttribute="turnInVo"
           onsubmit="return formCancelLeaveHospLoad('turnOutForm','inputForm','${ctx}/nurse/wardCirculation/saveCancelLeaveHospPatient','${ctx}/doctor/patVisit/index');"
           method="post" class="form-horizontal">
    <form:hidden path="id"/>
    <form:hidden path="patientId"/>
    <form:hidden path="patVisitId"/>
    <form:hidden path="bedRecId" id="bedRecId"/>
    <div class="form-group">
        <label class="col-sm-4 control-label">姓名：</label>

        <div class="col-sm-8">
            <form:input path="name" htmlEscape="false" class="form-control" maxlength="32" readonly="true"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-4 control-label">性别：</label>

        <div class="col-sm-8">
            <form:select path="sex" id="sex" class="form-control" data-parsley-required="true" disabled="true">
                <form:options items="${fns:getDictList('SEX_DICT')}" itemLabel="label" itemValue="value"
                              htmlEscape="false"/>
            </form:select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-4 control-label">预交金：</label>

        <div class="col-sm-8">
            <input class="form-control" maxlength="20" readonly value="${turnInVo.prepayments}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-4 control-label">出院科室：</label>

        <div class="col-sm-8">
            <input readonly class="form-control"  value="${fns:getDeptName(turnInVo.deptDischargeTo,'' )}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-4 control-label">出院病区：</label>

        <div class="col-sm-8">
            <input readonly class="form-control" value="${fns:getDeptName(turnInVo.wardDischargeTo,'' )}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-4 control-label">出院时间：</label>

        <div class="col-sm-8">
            <input class="form-control" maxlength="20" readonly
                   value="<fmt:formatDate value="${turnInVo.dischargeDate}" pattern="yyyy-MM-dd hh:mm:ss"></fmt:formatDate>"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-4 control-label">新入住床位：</label>

        <div class="col-sm-8">
            <form:input path="bedNo"  id="bedNo" htmlEscape="false" class="form-control" maxlength="32" readonly="true" data-parsley-required="true"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-4 control-label">新入住科室：</label>

        <div class="col-sm-8">
            <sys:treeselect selectedParent="true"  method="selectedDoctor" id="deptStayed" name="deptStayed" value="${turnInVo.deptStayed}" isnull="true"
                            update="${not empty turnInVo.deptStayed}"
                            labelName="${fns:getDeptName(turnInVo.deptStayed,'' )}"
                            labelValue="${fns:getDeptName(turnInVo.deptStayed,'' )}"
                            title="科室" url="/sys/orgDept/treeData" cssClass="form-control"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-4 control-label">新入住病区：</label>

        <div class="col-sm-8">
            <sys:treeselect selectedParent="true" id="wardCode" name="wardCode" value="${turnInVo.wardCode}" isnull="true"
                            update="${not empty turnInVo.wardCode}"
                            labelName="${fns:getDeptName(turnInVo.wardCode,'' )}"
                            labelValue="${fns:getDeptName(turnInVo.wardCode,'' )}"
                            title="科室" url="/sys/orgDept/treeData?clinicAttrs=2" cssClass="form-control"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-4 control-label">经治医生：</label>

        <div class="col-sm-8">
            <input type="hidden" value="${turnInVo.doctorInCharge}" id="doctorInChargeId">
            <form:select path="doctorInCharge" id="doctorInCharge" class="form-control" data-parsley-required="true">
                <form:option value="" label="请选择"></form:option>
            </form:select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-4 control-label">上级医生：</label>

        <div class="col-sm-8">
            <input type="hidden" value="${turnInVo.upperDoctor}" id="upperDoctorId">
            <form:select path="upperDoctor" id="upperDoctor" class="form-control" data-parsley-required="true">
                <form:option value="" label="请选择"></form:option>
            </form:select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-4 control-label">主任医生：</label>

        <div class="col-sm-8">
            <input type="hidden" value="${turnInVo.directorDoctor}" id="directorDoctorId">
            <form:select path="directorDoctor" id="directorDoctor" class="form-control" data-parsley-required="true">
                <form:option value="" label="请选择"></form:option>
            </form:select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-4 control-label">责任护士：</label>

        <div class="col-sm-8">
            <input type="hidden" name="dutyNurse" value="${user.id}">
            <input type="text" value="${user.name}" class="form-control" required="true">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-4 control-label">质控护士：</label>

        <div class="col-sm-8">
            <select name="qualityNurse" class="form-control" required="true">
                <c:forEach items="${users}" var="u">
                    <option value="${u.id}"
                            <c:if test="${turnInVo.qualityNurse eq u.id}">selected</c:if>>${u.name}</option>
                </c:forEach>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-4 control-label">最后一次计费时间：</label>
        <div class="col-sm-8">
            <input class="form-control" name="lastAcctDateTim" maxlength="20" readonly value="<fmt:formatDate value="${turnInVo.lastAcctDateTim}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate>"/>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <input id="btnSubmit" class="btn btn-primary" type="submit" value="确 定">&nbsp;
            <input id="btnCancel" class="btn" type="button" value="关 闭" onclick="closeCancelLeaveHospForm()">
        </div>
    </div>
</form:form>
